package com.zenchn.entity;


import com.fasterxml.jackson.annotation.JsonInclude;

/**
 * JsonResult
 * @author dingxinfa
 * @date 2018-07-07
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class JsonResult<T> extends Result {

    private static final long serialVersionUID = -470082323581791420L;
    /**
     * 数据
     */
    private T data;



    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public JsonResult() {
        super();
    }

    /**
     * 自定义返回的结果
     *
     * @param data
     * @param code
     * @param message
     * @param success
     */
    public JsonResult(T data, Integer code,String message, boolean success) {
        this.data = data;
        super.setCode(code);
        super.setMessage(message);
        super.setSuccess(success);
    }

    /**
     * 成功返回数据和消息
     *
     * @param data
     * @param message
     */
    public JsonResult(T data, String message) {
        this.data = data;
        super.setMessage(message);
        super.setSuccess(true);
    }

    /**
     * 成功返回数据
     *
     * @param data
     */
    public JsonResult(T data) {
        this.data = data;
        super.setSuccess(true);
    }
}